package com.dss.auto_deploy.listener;

import com.dss.auto_deploy.event.StartToDeployEvent;
import com.dss.auto_deploy.service.IDeployService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description:
 * @author: dongshoushan
 */
@Slf4j
@Component
@AllArgsConstructor
public class StartToDeployListener {
    @Resource
    private IDeployService deployService;

    @Async
    @Order
    @EventListener(StartToDeployEvent.class)
    public void run(StartToDeployEvent event) throws Exception {
        log.info("==============请求成功执行部署任务ID:{}=================", event.getIds());
        deployService.deploySelect(event.getIds());
    }
}
